
/**
 * AJAX 载入用户发送飞信页面
 *
 * @return void
 */
function bindUserFetion() {
	$("#ajax-fetion-link").click(function(){
		$(".slider-item a").removeClass('selected-slider-item');
		$(this).addClass('selected-slider-item').blur();
		addMmLightBoxMsg('Wait a moment please, loading data ...', 0, 0, 1);
		$.get($(this).attr('href'), function(dt){
			$('#user-body-box').height('auto').html(dt);
			reactHeight();
			removeMmLightBoxMsg();
			$("#fetion-form").submit(function(){
				sendFetionSms($(this).attr('action'), $("#sender-input").val(), $("#passwd-input").val(), $("#receiver-input").val(), $("#sms-input").val());
				return false;
			});
		});
		return false;
	});
}

/**
 * AJAX 发送飞信信息
 *
 * @param 	string 		save_url 	POST提交发送飞信地址
 * @param 	string 		sender 		发送者手机号码
 * @param 	string 		passwd 		发送者飞信密码
 * @param 	string 		receiver 	接收者手机号码
 * @param 	string 		sms 		短信你内容
 * @return 	boolean
 */
function sendFetionSms(save_url, sender, passwd, receiver, sms) {
	if(!sender || !passwd || !receiver || !sms) {
		addMmLightBoxMsg('Sorry! Some data is empty! You need input all fields!', 1, 1);
		return false;
	}
	addMmLightBoxMsg('Wait a moment please, send message ...', 0, 0, 1);
	$("#fetion-submit").attr("disabled", true);
	$.post(save_url, {'sender':sender, 'passwd':passwd, 'receiver':receiver, 'sms':sms},function(dt){
		if(!dt.result){
			addMmLightBoxMsg(dt.msg, 1, 1);
		} else {
			$("#receiver-input").val('');
			$("#sms-input").val('');
			addMmLightBoxMsg(dt.msg, 1);
			window.setTimeout(function(){removeMmLightBoxMsg();}, 2000);
		}
		$("#fetion-submit").attr("disabled", false);
	}, 'json');
	return true;
}
